﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NLog;

namespace Gollie.Payment.Targetpay
{
	public partial class IdealCheckHandler : System.Web.UI.Page
	{
		private static Logger logger = LogManager.GetCurrentClassLogger();

		protected void Page_Load(object sender, EventArgs e)
		{
			logger.Info("Checkhandler: Handling TargetPay payment...");

			//string transactionId = this.Request["transaction_id"]; // mollie
			string transactionId = this.Request["trxid"]; //targetpay

			try
			{
				IDealHandler idealHandler = new IDealHandler(transactionId, true);

				idealHandler.Handle();
			}
			catch (Exception ex)
			{
				logger.ErrorException("Error handling iDEAL:", ex);
			}

			Response.ContentType = Gollie.Mime.MimeMapping.GetMimeMapping(".txt");
			Response.Output.Write("OK");
			Response.OutputStream.Flush();
			Response.End();
		}
	}
}